package com.nhim.cms.admin.server.locator;

import com.google.gwt.requestfactory.shared.Locator;
import com.nhim.cms.dao.CustomWidgetDAO;
import com.nhim.cms.domain.CustomWidget;
import com.nhim.cms.util.AppContext;

public class CustomWidgetLocator extends Locator<CustomWidget, Integer> {
	
	
	CustomWidgetDAO customWidgetDAO = CustomWidgetDAO.getFromApplicationContext(AppContext.getApplicationContext());
	
	
	@Override
	public CustomWidget create(Class<? extends CustomWidget> clazz) {
		return new CustomWidget();
	}

	@Override
	public CustomWidget find(Class<? extends CustomWidget> clazz, Integer id) {
		if (id == null)
			return new CustomWidget();
		return customWidgetDAO.findById(id);
	}

	@Override
	public Class<CustomWidget> getDomainType() {
		return CustomWidget.class;
	}

	@Override
	public Integer getId(CustomWidget domainObject) {
		return domainObject.getId();
	}

	@Override
	public Class<Integer> getIdType() {
		return Integer.class;
	}

	@Override
	public Object getVersion(CustomWidget domainObject) {
		return domainObject.getVersion();
	}

}
